// pages/weather/index.js
Page({

    data: {
        city: "厦门",
        wImage: "/images/w1.png"

    },
    //获取天气预报
    mysubmit: function(res) {
        this.setData({
            city: res.detail.value.icity
        })
        this.getWeatherInfo();
    },
    getWeatherInfo: function() {
        var that = this;
        wx.request({
            url: 'https://api.jisuapi.com/weather/query',
            data: {
                appkey: "e3168847d4a89517",
                city: that.data.city
            },
            success: function(res) {
                // console.log(res);
                that.setData({
                    date: res.header.Date,
                    city: that.data.city
                })
                var weather = JSON.stringify(res.header.Date);
                console.log(weather);
                // if (weather.indexOf("晴") > 0) {
                //     that.setData({
                //         wImage: "/images/w1.png"
                //     })
                // } else if (weather.indexOf("雨") > 0) {
                //     that.setData({
                //         wImage: "/images/w3.png"
                //     })
                // } else if (weather.indexOf("云") > 0 || weather.indexOf("阴") > 0) {
                //     that.setData({
                //         wImage: "/images/w2.png"
                //     })
                // }
            }
        })
    },


    onLoad: function(options) {
        this.getWeatherInfo();
    },


    onReady: function() {

    },


    onShow: function() {

    },


    onHide: function() {

    },


})